<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<!-- remove old header -->


<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>cogen API Reference Documentation
        - Module: reactors</title><meta name="MSSmartTagsPreventParsing" content="true" /><meta http-equiv="imagetoolbar" content="no" /><link href="css/default.css" rel="stylesheet" type="text/css" /><link href="css/pygments.css" rel="stylesheet" type="text/css" />
    <!-- <link rel="shortcut icon" href="/images/favicon.ico" type="image/vnd.microsoft.icon"/> -->
    <link rel="stylesheet" href="css/apydia.css" type="text/css" />
    <script src="js/jquery-1.2.1.pack.js" type="text/javascript"></script>
    <script src="js/apydia.js" type="text/javascript"></script>
	<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
</head>
<body>
    <div id="page">
        <div id="browser">
            <div class="browser-section">
                <h2>Module Index</h2>
                <ul>
                    <li>
                        <a href="cogen.html">cogen</a>
                    </li><li>
                        <a href="cogen.common.html">cogen.common</a>
                    </li><li>
                        <a href="cogen.core.html">cogen.core</a>
                    </li><li>
                        <a href="cogen.core.coroutines.html">cogen.core.coroutines</a>
                    </li><li>
                        <a href="cogen.core.events.html">cogen.core.events</a>
                    </li><li>
                        <a href="cogen.core.pubsub.html">cogen.core.pubsub</a>
                    </li><li>
                        <a href="cogen.core.queue.html">cogen.core.queue</a>
                    </li><li class="active">
                        <a href="cogen.core.reactors.html">cogen.core.reactors</a>
                    </li><li>
                        <a href="cogen.core.reactors.base.html">cogen.core.reactors.base</a>
                    </li><li>
                        <a href="cogen.core.reactors.iocp_proactor.html">cogen.core.reactors.iocp_proactor</a>
                    </li><li>
                        <a href="cogen.core.reactors.poll_reactor.html">cogen.core.reactors.poll_reactor</a>
                    </li><li>
                        <a href="cogen.core.reactors.qt_reactor.html">cogen.core.reactors.qt_reactor</a>
                    </li><li>
                        <a href="cogen.core.reactors.select_reactor.html">cogen.core.reactors.select_reactor</a>
                    </li><li>
                        <a href="cogen.core.schedulers.html">cogen.core.schedulers</a>
                    </li><li>
                        <a href="cogen.core.sockets.html">cogen.core.sockets</a>
                    </li><li>
                        <a href="cogen.core.util.html">cogen.core.util</a>
                    </li><li>
                        <a href="cogen.web.html">cogen.web</a>
                    </li><li>
                        <a href="cogen.web.async.html">cogen.web.async</a>
                    </li><li>
                        <a href="cogen.web.wsgi.html">cogen.web.wsgi</a>
                    </li>
                </ul>
            </div>
            <div class="browser-section">
                <h2>Submodules</h2>
                <ul>
                    <li>
                        <a href="cogen.core.reactors.base.html">base</a>
                    </li><li>
                        <a href="cogen.core.reactors.iocp_proactor.html">iocp_proactor</a>
                    </li><li>
                        <a href="cogen.core.reactors.poll_reactor.html">poll_reactor</a>
                    </li><li>
                        <a href="cogen.core.reactors.qt_reactor.html">qt_reactor</a>
                    </li><li>
                        <a href="cogen.core.reactors.select_reactor.html">select_reactor</a>
                    </li>
                </ul>
            </div>
            <div class="browser-section">
                <h2>Functions</h2>
                <ul>
                    <li>
                        <a href="cogen.core.reactors.html#function-get_first">get_first</a>
                    </li><li>
                        <a href="cogen.core.reactors.html#function-has_any">has_any</a>
                    </li><li>
                        <a href="cogen.core.reactors.html#function-has_epoll">has_epoll</a>
                    </li><li>
                        <a href="cogen.core.reactors.html#function-has_iocp">has_iocp</a>
                    </li><li>
                        <a href="cogen.core.reactors.html#function-has_kqueue">has_kqueue</a>
                    </li><li>
                        <a href="cogen.core.reactors.html#function-has_poll">has_poll</a>
                    </li><li>
                        <a href="cogen.core.reactors.html#function-has_qt">has_qt</a>
                    </li><li>
                        <a href="cogen.core.reactors.html#function-has_select">has_select</a>
                    </li>
                </ul>
            </div>
        </div>
        <div id="content">
    <h1>Module:
        cogen.core.reactors
    </h1>
    <div class="docstring rst"><p>Network polling code.</p>
<p>The reactor works in tandem with the socket operations.
Here's the basic workflow:</p>
<ul class="simple">
<li>the coroutine yields a operation</li>
<li>the scheduler runs that operation (the <a class="reference" href="cogen.core.events.Operation.html#method-process">process</a> method)
Note: all the socket operations share the same <a class="reference" href="cogen.core.sockets.SocketOperation.html#method-process">process method</a>.<ul>
<li>if run_first is False then the operation is added in the reactor for
polling (with the exception that if we have data in out internal buffers
the operation is runned first)</li>
<li>if run_first is set (it's default) in the operation then in process
method the reactor's <a class="reference" href="cogen.core.reactors.ReactorBase#method-run_or_add">run_or_add</a> is called with the
operation and coroutine</li>
</ul>
</li>
</ul>
<p>Note: run_first is a optimization hack really, first it tries to run the
operation (this asumes the sockets are usualy ready) and if it raises any
exceptions like EAGAIN, EWOULDBLOCK etc it adds that operation for polling
(via select, epoll, kqueue etc) then the run method will be called only when
select, epoll, kqueue says that the socket is ready.</p>
</div>
    <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#1">View source</a>
    </li>
</ul>
    <div>
        <h2>Modules</h2>
            <h3>
                <a href="cogen.core.reactors.base.html">base</a>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li>
        <a href="cogen.core.reactors.base.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/base.py#1">View source</a>
    </li>
</ul>
            <h3>
                <a href="cogen.core.reactors.iocp_proactor.html">iocp_proactor</a>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li>
        <a href="cogen.core.reactors.iocp_proactor.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/iocp_proactor.py#1">View source</a>
    </li>
</ul>
            <h3>
                <a href="cogen.core.reactors.poll_reactor.html">poll_reactor</a>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li>
        <a href="cogen.core.reactors.poll_reactor.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/poll_reactor.py#1">View source</a>
    </li>
</ul>
            <h3>
                <a href="cogen.core.reactors.qt_reactor.html">qt_reactor</a>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li>
        <a href="cogen.core.reactors.qt_reactor.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/qt_reactor.py#1">View source</a>
    </li>
</ul>
            <h3>
                <a href="cogen.core.reactors.select_reactor.html">select_reactor</a>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li>
        <a href="cogen.core.reactors.select_reactor.html">Details</a>
    </li>
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/select_reactor.py#1">View source</a>
    </li>
</ul>
    </div>
    <div>
        <h2>Functions</h2>
            <h3 id="function-get_first">
                get_first
                <span class="args">(*imps)</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#90">View source</a>
    </li>
</ul>
            <h3 id="function-has_any">
                has_any
                <span class="args">()</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#96">View source</a>
    </li>
</ul>
            <h3 id="function-has_epoll">
                has_epoll
                <span class="args">()</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#49">View source</a>
    </li>
</ul>
            <h3 id="function-has_iocp">
                has_iocp
                <span class="args">()</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#67">View source</a>
    </li>
</ul>
            <h3 id="function-has_kqueue">
                has_kqueue
                <span class="args">()</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#57">View source</a>
    </li>
</ul>
            <h3 id="function-has_poll">
                has_poll
                <span class="args">()</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#39">View source</a>
    </li>
</ul>
            <h3 id="function-has_qt">
                has_qt
                <span class="args">()</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#81">View source</a>
    </li>
</ul>
            <h3 id="function-has_select">
                has_select
                <span class="args">()</span>
            </h3>
            <div class="docstring rst"></div>
            <ul class="link-bar">
    <li class="link-to-sourcecode">
        <a href="http://code.google.com/p/cogen/source/browse/trunk/cogen/core/reactors/__init__.py#30">View source</a>
    </li>
</ul>
    </div>
        </div>
        <div id="footer">
            Generated with <a href="http://apydia.ematia.de/" class="extern">
            Apydia 0.0.3</a>
        </div>
    </div>
</body>
</html>